{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sqlite3\n",
    "conn = sqlite3.connect(\"test.db\")\n",
    "cursor = conn.cursor()\n",
    "cursor.execute(\"drop table CliSearch\")\n",
    "conn.commit()\n",
    "cursor.close()\n",
    "conn.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[(0, 'note0', 'disp tm link0'), (1, 'note1', 'disp tm link1'), (2, 'note2', 'disp tm link2'), (3, 'note3', 'disp tm link3'), (4, 'note4', 'disp tm link4'), (5, 'note5', 'disp tm link5'), (6, 'note6', 'disp tm link6'), (7, 'note7', 'disp tm link7'), (8, 'note8', 'disp tm link8'), (9, 'note9', 'disp tm link9'), (10, 'note10', 'disp tm link10'), (11, 'note11', 'disp tm link11'), (12, 'note12', 'disp tm link12'), (13, 'note13', 'disp tm link13'), (14, 'note14', 'disp tm link14'), (15, 'note15', 'disp tm link15'), (16, 'note16', 'disp tm link16'), (17, 'note17', 'disp tm link17'), (18, 'note18', 'disp tm link18'), (19, 'note19', 'disp tm link19'), (20, 'note20', 'disp tm link20'), (21, 'note21', 'disp tm link21'), (22, 'note22', 'disp tm link22'), (23, 'note23', 'disp tm link23'), (24, 'note24', 'disp tm link24'), (25, 'note25', 'disp tm link25'), (26, 'note26', 'disp tm link26'), (27, 'note27', 'disp tm link27'), (28, 'note28', 'disp tm link28'), (29, 'note29', 'disp tm link29'), (30, 'note30', 'disp tm link30'), (31, 'note31', 'disp tm link31'), (32, 'note32', 'disp tm link32'), (33, 'note33', 'disp tm link33'), (34, 'note34', 'disp tm link34'), (35, 'note35', 'disp tm link35'), (36, 'note36', 'disp tm link36'), (37, 'note37', 'disp tm link37'), (38, 'note38', 'disp tm link38'), (39, 'note39', 'disp tm link39'), (40, 'note40', 'disp tm link40'), (41, 'note41', 'disp tm link41'), (42, 'note42', 'disp tm link42'), (43, 'note43', 'disp tm link43'), (44, 'note44', 'disp tm link44'), (45, 'note45', 'disp tm link45'), (46, 'note46', 'disp tm link46'), (47, 'note47', 'disp tm link47'), (48, 'note48', 'disp tm link48'), (49, 'note49', 'disp tm link49'), (50, 'note50', 'disp tm link50'), (51, 'note51', 'disp tm link51'), (52, 'note52', 'disp tm link52'), (53, 'note53', 'disp tm link53'), (54, 'note54', 'disp tm link54'), (55, 'note55', 'disp tm link55'), (56, 'note56', 'disp tm link56'), (57, 'note57', 'disp tm link57'), (58, 'note58', 'disp tm link58'), (59, 'note59', 'disp tm link59'), (60, 'note60', 'disp tm link60'), (61, 'note61', 'disp tm link61'), (62, 'note62', 'disp tm link62'), (63, 'note63', 'disp tm link63'), (64, 'note64', 'disp tm link64'), (65, 'note65', 'disp tm link65'), (66, 'note66', 'disp tm link66'), (67, 'note67', 'disp tm link67'), (68, 'note68', 'disp tm link68'), (69, 'note69', 'disp tm link69'), (70, 'note70', 'disp tm link70'), (71, 'note71', 'disp tm link71'), (72, 'note72', 'disp tm link72'), (73, 'note73', 'disp tm link73'), (74, 'note74', 'disp tm link74'), (75, 'note75', 'disp tm link75'), (76, 'note76', 'disp tm link76'), (77, 'note77', 'disp tm link77'), (78, 'note78', 'disp tm link78'), (79, 'note79', 'disp tm link79'), (80, 'note80', 'disp tm link80'), (81, 'note81', 'disp tm link81'), (82, 'note82', 'disp tm link82'), (83, 'note83', 'disp tm link83'), (84, 'note84', 'disp tm link84'), (85, 'note85', 'disp tm link85'), (86, 'note86', 'disp tm link86'), (87, 'note87', 'disp tm link87'), (88, 'note88', 'disp tm link88'), (89, 'note89', 'disp tm link89'), (90, 'note90', 'disp tm link90'), (91, 'note91', 'disp tm link91'), (92, 'note92', 'disp tm link92'), (93, 'note93', 'disp tm link93'), (94, 'note94', 'disp tm link94'), (95, 'note95', 'disp tm link95'), (96, 'note96', 'disp tm link96'), (97, 'note97', 'disp tm link97'), (98, 'note98', 'disp tm link98'), (99, 'note99', 'disp tm link99')]\n"
     ]
    }
   ],
   "source": [
    "import sqlite3\n",
    "conn = sqlite3.connect(\"test.db\")\n",
    "cursor = conn.cursor()\n",
    "cursor.execute(\"\"\"create table if not exists CliSearch(\n",
    "    mid interger,\n",
    "    cmd TEXT,\n",
    "    note TEXT)\"\"\")\n",
    "conn.commit()\n",
    "for i in range(100):\n",
    "    cursor.execute(\"\"\"INSERT INTO CliSearch VALUES(?,?,?)\"\"\", (i,  \"disp tm link\" + str(i),\"ngsf\" ))\n",
    "# conn.commit()\n",
    "# cursor.close()\n",
    "# conn.close()\n",
    "cursor.execute(\"select * from CliSearch\")\n",
    "print(cursor.fetchall())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "select * from CliSearch where cli glob '*tm*link*'\n"
     ]
    },
    {
     "ename": "ProgrammingError",
     "evalue": "Cannot operate on a closed cursor.",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mProgrammingError\u001b[0m                          Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[14], line 6\u001b[0m\n\u001b[0;32m      4\u001b[0m dataStr3 \u001b[39m=\u001b[39m dataStr\u001b[39m+\u001b[39mdataStr2 \u001b[39m+\u001b[39m endStr\n\u001b[0;32m      5\u001b[0m \u001b[39mprint\u001b[39m(dataStr3)\n\u001b[1;32m----> 6\u001b[0m cursor\u001b[39m.\u001b[39;49mexecute(dataStr3)\n\u001b[0;32m      7\u001b[0m \u001b[39mprint\u001b[39m(cursor\u001b[39m.\u001b[39mfetchall())\n",
      "\u001b[1;31mProgrammingError\u001b[0m: Cannot operate on a closed cursor."
     ]
    }
   ],
   "source": [
    "dataStr = \"select * from CliSearch where cli glob '*\"\n",
    "dataStr2 = \"tm*link\"\n",
    "endStr = \"*'\"\n",
    "dataStr3 = dataStr+dataStr2 + endStr\n",
    "print(dataStr3)\n",
    "cursor.execute(dataStr3)\n",
    "print(cursor.fetchall())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "conn.commit()\n",
    "cursor.close()\n",
    "conn.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = \"mid: 0x901 cmd:disp tm link crc\"\n",
    "import re\n",
    "b = \"\"\n",
    "res = re.findall(\"fjeaifiwaj\",a)\n",
    "if (res):\n",
    "    print(res)\n",
    "    print(1)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
